package cn.pli.bike.ui;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.framemodule.BaseApp.Setting;
import com.framemodule.base.BaseDelegate;

import java.util.ArrayList;
import java.util.List;

import cn.pli.bike.R;
import cn.pli.bike.bean.SettingBean;
import cn.pli.bike.bean.UserInfoSetBean;

/**
 * Created by shangdongzhou on 2017/11/8.
 */

public class SettingDelegate extends BaseDelegate {
    public static final int CLEAR_CACHE = 0;
    public static final int CHECK_UPDATE = 1;

    private RecyclerView recyclerView;
    private SettingAdapter userInfoAdapter;
    private static int[] titles = {R.string.clear_cache, R.string.check_update};
    private static int[] url = {CLEAR_CACHE, CHECK_UPDATE};
    private List<SettingBean> userInfos;


    @Override
    public void initTitleBar() {

    }

    @Override
    public int getRootLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    public void initWidget() {
        super.initWidget();
        recyclerView = get(R.id.recycler_user_info);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        userInfoAdapter = new SettingAdapter(recyclerView);
        recyclerView.setAdapter(userInfoAdapter);
        userInfos = new ArrayList<>();
        setData();

    }

    public void setData() {
        userInfos.clear();
        for (int i = 0; i < titles.length; i++) {
            userInfos.add(new SettingBean(getResources().getString(titles[i]), url[i] + "")
            );
        }
        userInfoAdapter.setData(userInfos);
    }


    public SettingAdapter getUserInfoAdapter() {
        return userInfoAdapter;
    }

    public void setUserInfoAdapter(SettingAdapter userInfoAdapter) {
        this.userInfoAdapter = userInfoAdapter;
    }


    public RecyclerView getRecyclerView() {
        return recyclerView;
    }
}
